<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="shortcut icon" href="favicon.ico"> <link href="./src/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
        <link href="./src/css/font-awesome.css?v=4.4.0" rel="stylesheet">
        <link href="./src/css/plugins/iCheck/custom.css" rel="stylesheet">
        <link href="./src/css/animate.css" rel="stylesheet">
        <link href="./src/css/style.css?v=4.1.0" rel="stylesheet">
        <link href="./src/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
        <script src="./src/js/My97DatePicker/WdatePicker.js"></script>
    </head>
    <body>
        <div class="ibox-content">
            <form class="form-horizontal">
                <input type="hidden" name="m" value="finance">
                <input type="hidden" name="a" value="Receivables">
                <div class="form-group">
                    <label class="col-sm-1 control-label" style="width: 100px;">公司信息：</label>

                    <div class="col-sm-2">
                        <select class="form-control m-b"  style="padding-top:2px;">
                            <option value='0' >什么鬼</option>
                        </select>
                    </div>
                    <label class="col-sm-1 control-label" style="width: 100px;">客户简称：</label>

                    <div class="col-sm-2">
                        <select class="form-control m-b" name='customid'  style="padding-top:2px;">
                            <option value='0'>全部</option>
                        
                            <?php foreach ($this->cus as $k => $v) { ?>
                                <option value='<?php echo $v['id'] ?>' <?php echo($this->customid == $v['id']) ? 'selected' : '' ?> ><?php echo $v['nickname'] ?></option>
                            <?php } ?>
                        </select>
                    </div>
                    <label class="col-sm-1 control-label"  style="width: 125px;">业务类型：</label>

                    <div class="col-sm-2">
                        <select class="form-control m-b"  name='service_id'  style="padding-top:2px;">
                            <option>全部</opiton>
                                <?php foreach ($this->service as $k => $v) { ?>
                                <option value="<?php echo $v['id'] ?>"<?php echo ($this->service_id == $v['id']) ? 'selected' : '' ?> ><?php echo $v['servicemode'] ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label" style="width: 100px;">跟单员：</label>

                    <div class="col-sm-2">
                        <select class="form-control m-b"  style="padding-top:2px;">
                            <option value='0' >什么鬼</option>
                        </select>
                    </div>
                    <label class="col-sm-1 control-label" style="width: 100px;">状态：</label>

                    <div class="col-sm-2">
                        <select class="form-control m-b" name="status" style="padding-top:2px;">
                            <option value='0'>全部</option>
                            <option value="1" <?php echo($this->status == 1) ? 'selected' : '' ?> >激活</option>
                            <option value="2" <?php echo($this->status == 2) ? 'selected' : '' ?> >休眠</option>
                        </select>
                    </div>
                    <label class="col-sm-1 control-label" style="width: 125px;">当前样式：</label>

                    <div class="col-sm-2">
                        <select class="form-control m-b"  style="padding-top:2px;">
                            <option value='0'>样式又是什么鬼</option>
                        </select>
                    </div>

                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label" style="width: 100px;">做箱时间:</label>
                    <div class="col-sm-4">
                        <div class="input-daterange input-group  m-b"  id="datepicker">
                            <input class="input-sm form-control" name="start" onfocus="WdatePicker({skin: 'whyGreen', dateFmt: 'yyyy-MM-dd'})"  value="<?php echo $this->start; ?>"  type="text">
                            <span class="input-group-addon">到</span>
                            <input class="input-sm form-control" name="end"  onfocus="WdatePicker({skin: 'whyGreen', dateFmt: 'yyyy-MM-dd'})"  value="<?php echo $this->end; ?>"  type="text">
                        </div>
                    </div>
                    <div class="col-sm-1">
                        <button class="btn btn-sm btn-info" type="submit">搜索</button>
                    </div>
                </div>
            </form>
        </div>
        <div class="row">
            <div class="ibox float-e-margins" style="width:98%;margin-left:1%;">
                <div class="ibox-title">
                    <button class="btn btn-success" style="margin-top:-10px;" type="button" id=""><span class="bold">预览</span></button>
                    <button class="btn btn-success" style="margin-top:-10px;" type="button" id="dao"><span class="bold">导出</span></button>    
                    <button class="btn btn-success" style="margin-top:-10px;" type="button" id=""><span class="bold">自定义</span></button>    
                </div>
                <div class="ibox-content">

                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>序号</th>
                                <th>客户</th>
                                <th>箱量</th>
                                <th>运费</th>
                                <th>落/还箱费</th>
                                <th>打/改单费</th>
                                <th>理货费</th>
                                <th>港杂费</th>
                                <th>坏/污箱费</th>
                                <th>代收费</th>
                                <th>小计</th>
                                <th>已收</th>
                                <th>未收</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                                $count1 = 0;
                                $countnumber = 0;
                                $count2 = 0;
                                $count3 = 0;
                                $count4 = 0;
                                $count5 = 0;
                                $count6 = 0;
                                $count7 = 0;
                                $xjcount = 0;
                            foreach ((array) @$this->custom as $k => $v) {
                                ?>
                                <tr>
                                    <td><?php echo $v['id'] ?></td>
                                    <td><?php echo $v['name'] ?></td>
                                    <td><?php
                                        $number = 0;
                                        foreach ((array) @$this->custom_id[$v['id']] as $a1 => $b1) {
                                
                                            $number1 = 0;
                                            foreach ((array) @$this->detail[$b1] as $a2 => $b2) {
                                                $number1 += $b2;
                                            }
                                            $number += $number1;
                                        }
                                        $countnumber += $number;
                                        echo $number;
                                        ?></td>
                                    <td>
                                        <?php
                                        $money1 = 0;
                                        foreach ((array) @$this->custom_id[$v['id']] as $a3 => $b3) {
                                            $number_1 = 0;
                                            foreach ((array) @$this->money[$b3] as $a4 => $b4) {
                                                // var_dump($b4);
                                                $number_1 += $b4['money_1'];
                                            }
                                            $money1 += $number_1;
                                        }
                                        $count1 += $money1;
                                        echo $money1;
                                        ?>
                                    </td>
                                    <td>
                                        <?php
                                        $money5 = 0;
                                        foreach ((array) @$this->custom_id[$v['id']] as $a5 => $b5) {
                                            $number_5 = 0;
                                            foreach ((array) @$this->money[$b5] as $a6 => $b6) {
                                                // var_dump($b4);
                                                $number_5 += $b6['money_5'];
                                            }
                                            $money5 += $number_5;
                                        }
                                        $count2 += $money5;
                                        echo $money5;
                                        ?>
                                    </td>
                                    <td>
                                        <?php
                                        $money6 = 0;
                                        foreach ((array) @$this->custom_id[$v['id']] as $a7 => $b7) {
                                            $number_6 = 0;
                                            foreach ((array) @$this->money[$b7] as $a8 => $b8) {
                                                // var_dump($b4);
                                                $number_6 += $b8['money_6'];
                                            }
                                            $money6 += $number_6;
                                        }
                                        $count3 += $money6;
                                        echo $money6;
                                        ?>
                                    </td>
                                    <td>
                                        <?php

                                        $money7 = 0;
                                        foreach ((array) @$this->custom_id[$v['id']] as $a9 => $b9) {
                                            $number_7 = 0;
                                            foreach ((array) @$this->money[$b9] as $a10 => $b10) {
                                                // var_dump($b4);
                                                $number_7 += $b10['money_7'];
                                            }
                                            $money7 += $number_7;
                                        }
                                        $count4 += $money7;
                                        echo $money7;
                                        ?>
                                    </td>
                                    <td>
                                        <?php
                                        $money10 = 0;
                                        foreach ((array) @$this->custom_id[$v['id']] as $a11 => $b11) {
                                            $number_10 = 0;
                                            foreach ((array) @$this->money[$b11] as $a12 => $b12) {
//                                                var_dump($b12);
                                                $number_10 += $b12['money_10'];
                                            }
                                            $money10 += $number_10;
                                        }
                                        $count5 += $money10;
                                        echo $money10;
                                        ?>
                                    </td>
                                    <td>
                                        <?php
                                        $money11 = 0;

                                        foreach ((array) @$this->custom_id[$v['id']] as $a13 => $b13) {
                                            $number_11 = 0;
                                            foreach ((array) @$this->money[$b13] as $a14 => $b14) {
                                                $number_11 += $b14['money_11'];
                                            }
                                            $money11 += $number_11;
                                        }
                                        $count6 += $money11;
                                        echo $money11;
                                        ?>
                                    </td>
                                    <td>
                                        <?php
                                        $money15 = 0;

                                        foreach ((array) @$this->custom_id[$v['id']] as $a15 => $b15) {
                                            $number_15 = 0;
                                            foreach ((array) @$this->money[$b15] as $a16 => $b16) {
                                                $number_15 += $b16['money_15'];
                                            }
                                            $money15 += $number_15;
                                        }
                                        $count7 += $money15;
                                        echo $money15;
                                        ?>
                                    </td>
                                    <td><?php
                                        $xj = $money1 + $money5 + $money6 + $money7 + $money10 + $money11 + $money15;
                                        $xjcount += $xj;
                                        echo $xj;
                                        ?></td>
                                    <td>这个已收是什么鬼</td>
                                    <td><?php echo $xj; ?></td>
                                </tr>
                                <?php
                            }
                            ?>     
                            <tr style="background:#CEDFF5;">
                                <td colspan="2">合计:</td>
                                <td><?php echo @$countnumber; ?></td>
                                <td><?php echo @$count1; ?></td>
                                <td><?php echo @$count2; ?></td>
                                <td><?php echo @$count3; ?></td>
                                <td><?php echo @$count4; ?></td>
                                <td><?php echo @$count5; ?></td>
                                <td><?php echo @$count6; ?></td>
                                <td><?php echo @$count7; ?></td>
                                <td><?php echo @$xjcount; ?></td>
                                <td></td>
                                <td><?php echo @$xjcount; ?></td>
                            </tr>
                            <tr style="background:#CEDFF5;">
                                <td colspan="2">合计(大写):</td>    
                                <td colspan="11"><?php echo get_amount(@$xjcount); ?></td>    
                            </tr>
                            <tr style="background:#CEDFF5;">
                                <td colspan="2">总箱型箱量:</td>
                                <td colspan="11"><?php
                                    $arr = array();
                                    foreach ($this->detail as $k => $v) {
                                        foreach ($v as $k1 => $v1) {
                                            for ($i = 0; $i < $v1; $i++) {
                                                $arr[] = $k1;
                                            }
                                        }
                                    }
                                    $titype = array_count_values($arr);
                                    $text = '';
                                    $b = '';
                                    foreach ($titype as $k => $v) {
                                        $text .= $b . @$this->box[$k]['code'] . "*" . $v;
                                        $b = ',';
                                    }
                                    echo $text;
                                    ?></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="admin-table-page" style="margin-left:20px;">
            <div id="page" class="page">
                <?php echo $this->paging; ?>
            </div>
        </div>
        <script src="./src/js/jquery.min.js?v=2.1.4"></script>
        <script src="./src/js/bootstrap.min.js?v=3.3.6"></script>



        <!-- 自定义js -->
        <script src="./src/js/content.js?v=1.0.0"></script>
        <script src="./src/js/plugins/sweetalert/sweetalert.min.js"></script>
        <script>
        $(function(){
        $("#dao").click(function(){
            location.href = "./?m=finance&a=Receivables&type=2";
        });
        });
         </script>                 
    </body>
</html>
